#pragma once

#include "Containers/String.h"
#include "Containers/Optional.h"
#include "Path/Path.h"
#include "AssetPath.m.h"

class CClass;

//资产引用路径
//for example you put a Texture2D asset in a packaged named EngineEditor
//create path like this:
//SAssetPath(Texture2D::StaticClass(),"EngineEditor","./","TestAsset")
RSTRUCT()
struct  WHENGINE_API SAssetPath
{
    ROBJECT

public:
    SAssetPath() {};

    SAssetPath(const CString& InPath);

    SAssetPath(CClass*  InAssetType
        , const CString& InPackageName
        , const CString& InFolderPathInPackage
        , const CString& InAssetName
        );

    //从资产包路径和资产文件路径中提取资产文件父文件夹在资产包中的路径
    static CString AbstractFolderPathInPackage(
        const SPath& InPackageFolderPath
        , const SPath& InAssetFilePath
    );
    //从资产文件路径中提取资产文名
    static CString AbstractAssetName(const SPath& InAssetFilePath);

    //abstract asset path from object path
    static SAssetPath CreateFrom(const CString& InObjectPath);

    //constructor for script
    RFUNCTION(ScriptConstructor)
    void Initialize(const CString& InStringExpression);

    SAssetPath& operator=(const SAssetPath& InOther);

    CString ToString()  const;

    CString GetPackageName() const;

    CString GetAssetName() const { return AssetName; };
    void SetAssetName(const CString& InAssetName);

    CString GetFolderPathInPackage() const;
    void SetFolderPathInPackage(const CString& InFolderPathInPackage);

    TVector<CString> GetFolderPathInPackageAsArray() const;

    uint64_t GetHashCode() const;

    bool operator==(const SAssetPath& Other) const;

    CClass* GetAssetType() const { return AssetType; }
protected:
    CClass* AssetType=nullptr;

    CString PackageName; //for example "EngineEditor"

    CString FolderPathInPackage;   //for example "./"

    CString AssetName;  //for example "TestAsset"
};